<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/base.css" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/style.css" />
    <title>半岛云</title>  
</head>
<body>
	<div class="wrap">
		<!--标题栏-->
		<div class="fixed_top">
			<div class="top-l"><a href="javascript:window.history.back()"><i class="icons">&#xe626;</i></a></div>
			<h1>注册</h1>
			<div class="top-r hide"><a href="javascript:;"><i class="icons">&#xe601;</i></a></div>
		</div>
		
		<!--主体区域-->
		<div class="container">
			<form class="login-form" id="userForm">
				<ul>
					<li>
						<label></label>
						<div class="username"><i class="icons">&#xe605;</i><input type="text" value="" name="username" id="username"   placeholder="请输入您的邮箱"/></div>
					</li>
					<li>
						<label></label>
						<div class="password"><i class="icons">&#xe787;</i><input type="password" value=""  name="password" id="password"  placeholder="请输入您的密码"/></div>
					</li>
					<li>
						<label></label>
						<div class="password"><i class="icons">&#xe787;</i><input type="password" value=""  name="passwordSub" id="passwordSub"  placeholder="请再次输入您的密码"/></div>
					</li>
					<li>
						<label></label>
						<div class="password"><i class="icons">&#xe60e;</i><input type="text" value=""  name="code" id="code" placeholder="请证明你不是机器人" class="login-code-input"/>							
							<a href="javascript:void(0);" onclick="changeImg()" class="aui-child aui-child-img"><img  class="login-code" src="/${BasePath}/user/validateCode" alt="" id="imgObj" /></a>
						</div>
					</li>
				</ul>
				<div class="tyxy">
					<i class="icons">&#xe607;</i>
					<i class="icons active">&#xe619;</i>
					<label>您已阅读并同意<a href="javascript:;">《注册协议》</a></label>
				</div>
				<div class="log">
					<a href="javascript:;" id="nextBtn" class="btn-login">注册</a>
				</div>
				<div class="log-more">
					<a class="btn-reg" href="loginx.html">立即登录</a>
				    <!-- <a href="password.html" class="btn-psw">忘记密码？</a> -->
				</div>
			</form>
		</div>
       
	</div>
</body>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/jquery-1.7.js" ></script>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/public.js" ></script>
<script type="text/javascript">
/*     $(function(){
    	var flag = true;
		var n=60;
		var timer=null;
		$(".hqyzm").click(function(){
			$(".hqyzm").addClass("hqyzming");
			clearInterval(timer);
			timer = setInterval(function() {
				n--;
				$(".hqyzm").text(n + "s后重新获取")
				if(n <= 0) {
					clearInterval(timer);
					n = 60;
					nowflag = true;
					flag = false;
					$(".hqyzm").text("获取验证码").removeClass("hqyzming");
				}
			}, 1000)
		})
		
		
		$(".tyxy i").click(function(){
			$(this).toggleClass("active").siblings("i").toggleClass("active")
		})
	}) */
	
	$(function(){
		//AJAX提交以及验证表单
		$('#nextBtn').click(function(){
			var username = $('#username').val();
			var passwd = $('#password').val();
			var passwd2 = $('#passwordSub').val();
			var verifyCode = $('#code').val();
			var usernameReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; //邮件正则
			if(username == ''){
				zz1('请填写您的邮箱~');
			}else if(!usernameReg.test(username)){
				zz1('您的邮箱格式错咯~');
			}else if(passwd == ''){
				zz1('请填写您的密码~');
			}else if(passwd2 == ''){
				zz1('请再次输入您的密码~');
			}else if(passwd != passwd2 || passwd2 != passwd){
				zz1('两次密码输入不一致呢~');
			}else if(verifyCode == ''){
				zz1('请输入验证码~');
			}else{
				$("#nextBtn").attr('disabled',true);
				$("#nextBtn").html("注册中...");
		        $.ajax({
		            type: 'post',
		            url: "/${BasePath}/user/doRegister",
		            data: $('#userForm').serialize(),
		            dataType: 'json',
		            success: function(data){
		                if (data.code == "1"){
		                	zz1(data.msg,"/${BasePath}/user/login",2500,);
		                }else {
		    				$("#nextBtn").attr('disabled',false);
		    				$("#nextBtn").html("注册");
		                	changeImg();
		                	zz1(data.msg);
		                }
		            }
		        });
			}
		});
		$(".tyxy i").click(function(){
			$(this).toggleClass("active").siblings("i").toggleClass("active")
		})
	});
   // 刷新图片
    function changeImg() {
        var imgSrc = $("#imgObj");
        var src = imgSrc.attr("src");
        imgSrc.attr("src", changeUrl(src));
    }
    //为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳
    function changeUrl(url) {
        var timestamp = (new Date()).valueOf();
        var index = url.indexOf("?",url);
        if (index > 0) { 
			 url = url.substring(0, index);
			}
        if ((url.indexOf("&") >= 0)) {
            url = url + "×tamp=" + timestamp;
        } else {
            url = url + "?timestamp=" + timestamp;
        }
        return url;
    }
</script>
</html>